//package com.zdx.yswl.ui.adapter;
//
//import android.content.Context;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.ViewGroup;
//import android.widget.TextView;
//
//import com.loopj.android.image.SmartImageView;
//import com.zdx.yswl.R;
//import com.zdx.yswl.tool.KNetTool;
//import com.zdx.yswl.ui.bean.LpBean;
//import com.zdx.yswl.ui.http.HttpUtilsByVolley;
//import com.zdx.yswl.view.listview.BaseListViewAdapter;
//
//public class LpInfoAdapter extends BaseListViewAdapter<LpBean> {
//
//	public LpInfoAdapter(Context _context) {
//		super(_context);
//	}
//	
//	@Override
//	public View getView(int position, View convertView, ViewGroup parent) {
//		ViewHolder __viewHolder = null;
//		if (convertView == null) {
//			convertView = LayoutInflater.from(this.context).inflate(R.layout.lp_listview_item, null);
//			__viewHolder = new ViewHolder();
//			__viewHolder.img = (SmartImageView) convertView.findViewById(R.id.lp_img);
//			__viewHolder.nameTv = (TextView) convertView.findViewById(R.id.lp_name_tv);
//			__viewHolder.addressTv = (TextView) convertView.findViewById(R.id.lp_addr_tv);
//			__viewHolder.promotionalTv = (TextView) convertView.findViewById(R.id.other_tv);
//			convertView.setTag(__viewHolder);
//		} else {
//			__viewHolder = (ViewHolder) convertView.getTag();
//		}
//
//		LpBean news = this.getItem(position);
//		
////		if (KNetTool.isNetworkAvalible(context)) {
////			__viewHolder.img.setImageUrl(news.coverUrl);
////		}else{
////			__viewHolder.img.setImageResource(R.drawable.aio_image_fail_round);
////		}
//		HttpUtilsByVolley.loadImage4Url(context, news.coverUrl, __viewHolder.img, R.drawable.aio_image_default_round, R.drawable.aio_image_fail_round);
//		if (news.coverUrl != null) {
//			__viewHolder.img.setImageUrl(news.coverUrl);
//		}else{
//			__viewHolder.img.setImageResource(R.drawable.aio_image_fail_round);
//		}
//		__viewHolder.nameTv.setText(news.projectName);
//		__viewHolder.addressTv.setText(news.place);
//		 String[] label = news.label;
//		 StringBuffer sb = new StringBuffer();
//		for (int i = 0; i < label.length; i++) {
//			sb.append(label[i] + " ");
//		}
//		__viewHolder.promotionalTv.setText(sb);
//		
//		
//		return convertView;
//	}
//
//	private static class ViewHolder {
//		public SmartImageView img;
//		public TextView nameTv;
//		public TextView addressTv;
//		public TextView promotionalTv;
//	}
//
//}

package com.zdx.yswl.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.loopj.android.image.SmartImageView;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
import com.zdx.yswl.R;
import com.zdx.yswl.ui.bean.LpBean;
import com.zdx.yswl.ui.listener.AnimateFirstDisplayListener;
import com.zdx.yswl.view.listview.BaseListViewAdapter;

public class LpInfoAdapter extends BaseListViewAdapter<LpBean> {

	private ImageLoadingListener animateFirstListener = new AnimateFirstDisplayListener();
	protected ImageLoader imageLoader = ImageLoader.getInstance();
	public LpInfoAdapter(Context _context) {
		super(_context);
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder __viewHolder = null;
		if (convertView == null) {
			convertView = LayoutInflater.from(this.context).inflate(R.layout.lp_listview_item, null);
			__viewHolder = new ViewHolder();
			__viewHolder.img = (SmartImageView) convertView.findViewById(R.id.lp_img);
			__viewHolder.nameTv = (TextView) convertView.findViewById(R.id.lp_name_tv);
			__viewHolder.addressTv = (TextView) convertView.findViewById(R.id.lp_addr_tv);
			__viewHolder.promotionalTv = (TextView) convertView.findViewById(R.id.other_tv);
			convertView.setTag(__viewHolder);
		} else {
			__viewHolder = (ViewHolder) convertView.getTag();
		}

		LpBean news = this.getItem(position);
		
//		__viewHolder.img.setImageUrl(news.coverUrl,R.drawable.aio_image_fail_round, R.drawable.aio_image_default_round);

//		HttpUtilsByVolley.loadImage4Url(context, news.coverUrl, __viewHolder.img, R.drawable.aio_image_default_round, R.drawable.aio_image_fail_round);
		
		/**imageloader 加载 */
		imageLoader.displayImage(news.coverUrl, __viewHolder.img, options, animateFirstListener);
		__viewHolder.nameTv.setText(news.projectName);
		__viewHolder.addressTv.setText(news.place);
		 String[] label = news.label;
		 StringBuffer sb = new StringBuffer();
		for (int i = 0; i < label.length; i++) {
			sb.append(label[i] + " ");
		}
		__viewHolder.promotionalTv.setText(sb);
		
		
		return convertView;
	}

	private static class ViewHolder {
		public SmartImageView img;
		public TextView nameTv;
		public TextView addressTv;
		public TextView promotionalTv;
	}

}

